package ioc.config;

import ioc.bean.People;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

@Configuration // 告诉 Spring 这是一个配置类
@ComponentScan // 默认扫描当前包(com.test.config)及其子包(com.test.config.*)
public class BeanRegisteredConfig {

    // 给容器中注册一个 Bean，类型为返回值的类型，id 默认是用方法名作为 id
    // @Bean("person123")
    public People person() {
        return new People("lisi", 20, "nice");
    }

    @Bean
    @Scope("singleton")
    public People tmp() {
        return new People();
    }
}